SUFFIX:=.cpp#文件后缀

#服务器部分的源文件和编译文件
offline_src:=$(wildcard offline/src/*$(SUFFIX))
online_src:=$(wildcard online/src/net/*$(SUFFIX)) $(wildcard online/src/task/*$(SUFFIX)) $(wildcard online/src/threadpool/*$(SUFFIX))
addtion_src:=server/server.cpp conf/Configuration.cpp log/Mylog.cpp offline/inc/tinyxml/tinyxml2.cpp
server_obj:=$(offline_src:$(SUFFIX)=.o) $(online_src:$(SUFFIX)=.o) $(addtion_src:$(SUFFIX)=.o)

#客户端部分的源文件和编译文件
client_src:=$(wildcard client/*$(SUFFIX))
client_obj:=$(client_src:$(SUFFIX)=.o)

ELF:=bin/server bin/client 
CFLAGS:=-g -Wall
CC:=g++# 编译器 

all:$(server_obj) $(client_obj) $(ELF)

bin/server:$(server_obj)
	$(CC) $(CFLAGS) -o $@ $^ -llog4cpp -ljsoncpp -pthread 

bin/client:$(client_obj)
	$(CC) $(CFLAGS) -o $@ $^ -ljsoncpp -pthread 

%.o:%$(SUFFIX)
	$(CC) -c $(CFLAGS) $^ -o $@

.PHONY:clean rebuild

clean:
	@rm -rf $(offline_obj) $(client_obj) || [ 1 ]

rebuild:clean all